package org.prem.jb.hibernate.jointable;

import java.util.List;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Table;


@Entity(name="STUDENT_JOIN_T")
@Table(name="STUDENT_JOIN_T")
public class Student {

	@Id @GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="STUD_ID")
	private int id;
	
	@Column(name="STUD_NAME")
	private String name;
	
	//@Embedded
	@ElementCollection(fetch=FetchType.EAGER)
	@JoinTable(name="STUDENT_ADDRESS",
		joinColumns=@JoinColumn(name="STD_ADR_ID")
	)
	private List<Address> addressList;
	
	@Embedded
	@AttributeOverrides({
		@AttributeOverride(name="doorNo",column=@Column(name="COL_DOOR_NO")),
		@AttributeOverride(name="street",column=@Column(name="COL_STREET")),
		@AttributeOverride(name="zipcode",column=@Column(name="COL_ZIPCODE"))
	})
	private Address collegeAddress;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<Address> getAddressList() {
		return addressList;
	}

	public void setAddressList(List<Address> addressList) {
		this.addressList = addressList;
	}

	public Address getCollegeAddress() {
		return collegeAddress;
	}

	public void setCollegeAddress(Address collegeAddress) {
		this.collegeAddress = collegeAddress;
	} 
	
	
}
